<template>
    <div class="">
        <div class="pr10">
            <div class="analyItem">
                <p class="analyItemTit tx-center">状态</p>
                <div class="analyItemCon">

                </div>
            </div>
        </div>
        <div class="thinScroll pr10" v-scrollHeight="100">
            <div class="analyItem">
                <p class="analyItemTit tx-center">积分</p>
                <div class="analyItemCon">
                    <p class="col-md-6">
                        <button :class="{'bgcolor':flg===1}" @click="change(1)">普级</button>
                        <span>积分</span><i class="cRed"> {{60+integral.aggregateIntegral-tIntegral-(JcountIntegral?JcountIntegral.deductFraction:0)-(TcountIntegral?TcountIntegral.deductFraction:0)}}分</i>
                    </p>
                    <p class="col-md-4">
                        <button :class="{'bgcolor':flg===2}" @click="change(2)">管级</button>
                        <span>积分</span><i class="cRed"> {{0+(countIntegral?countIntegral.integtral:0)}}分</i>
                    </p>
                </div>
            </div>
            <!-- 普级 -->
            <div v-if="flg == 1">
                <router-link tag="div"  :to="routerPath('integralComplaints')" class="analyItem anItemBor" active-class="anItemBor-active">
                    <p class="analyItemTit tx-center">投诉</p>
                    <div class="analyItemCon">
                        <p class="col-md-4">
                            <span class="cLightGray pr8">投诉积分-</span>
                            <span class="cRed">{{tIntegral}}分</span>
                        </p>
                    </div>
                </router-link>
                <router-link tag="div" :to="routerPath('integralRejecte')" class="analyItem anItemBor" active-class="anItemBor-active">
                    <p class="analyItemTit tx-center">拒单</p>
                    <div class="analyItemCon">
                        <p class="col-md-4">
                            <span class="cLightGray pr8">当前-</span>
                            <span class="cRed">{{JcountIntegral?(JcountIntegral.deductFraction):0}}分</span>
                        </p>
                    </div>
                </router-link>
                <router-link tag="div" :to="routerPath('integralRefund')" class="analyItem anItemBor" active-class="anItemBor-active">
                    <p class="analyItemTit tx-center">退单</p>
                    <div class="analyItemCon">
                        <p class="col-md-4">
                            <span class="cLightGray pr8">当前-</span>
                            <span class="cRed">{{TcountIntegral?TcountIntegral.deductFraction:0}}分</span>
                        </p>
                    </div>
                </router-link>
            </div>
            <div v-if="flg == 2">
                <router-link tag="div"  :to="routerPath('integralPenalty')" class="analyItem anItemBor" active-class="anItemBor-active">
                    <p class="analyItemTit tx-center">管理</p>
                    <div class="analyItemCon">
                        <p class="col-md-4">
                            <span class="cLightGray pr8">处理-</span>
                            <span class="cRed">{{countIntegral?countIntegral.integtral:0}}分</span>
                        </p>
                    </div>
                </router-link>
            </div>
        </div>
        <div class="pr10">
            <router-link tag="div"  :to="routerPath('integralCount')" class="analyItem anItemBor" active-class="anItemBor-active">
                <p class="analyItemTit tx-center">综合</p>
                <div class="analyItemCon">
                    <p class="col-md-3">
                        <span>普级</span>
                    </p>
                    <p class="col-md-3">
                        <span>奖</span>
                        <span>{{integral.aggregateIntegral}}分</span>
                    </p>
                    <p class="col-md-3">
                        <span>罚</span>
                        <span>{{integral.aggregateIntegral}}分</span>
                    </p>
                    <!--                  <p class="col-md-4">
                                <span>{{integral.userLevel}}级降{{integral.nextLevel}} 级</span>
                            </p> -->
                    <p class="col-md-3">
                        <span>持有</span>
                        <span>{{60-Number(tIntegral-(JcountIntegral?JcountIntegral.deductFraction:0)-(TcountIntegral?TcountIntegral.deductFraction:0))}}分</span>
                    </p>
                    <p class="col-md-3">
                        <span>管级</span>
                    </p>
                    <p class="col-md-3">
                        <span>奖</span>
                        <span>0分</span>
                    </p>
                    <p class="col-md-3">
                        <span>罚</span>
                        <span>0分</span>
                    </p>
                    <!--                  <p class="col-md-4">
                                <span>{{integral.userLevel}}级降{{integral.nextLevel}} 级</span>
                            </p> -->
                    <p class="col-md-3">
                        <span>持有</span>
                        <span>{{0-Number(tIntegral-(JcountIntegral?JcountIntegral.deductFraction:0)-(TcountIntegral?TcountIntegral.deductFraction:0))}}分</span>
                    </p>
                </div>
            </router-link>
        </div>
    </div>

</template>
<script>
import { mapGetters } from 'vuex'
import { getIntegralMsg, getIntegralStatus, PersonHandlerIntegralNum, countcomplaintsIntegral, getProblemIntegral } from '../Resources/Api'
export default {
    data () {
        return {
            integral: {},
            JcountIntegral: {},
            TcountIntegral: {},
            countIntegral: {},
            complaints: {},
            tIntegralObject: [],
            tIntegral: 0,
            flg: 1
        }
    },
    created () {
        this.GetIntegral()
        this.GetJCountIntegral()
        this.GetTCountIntegral()
        this.countHandlerIntegral()
        this.countComplaints()
        this.ProblemIntegral()
    },
    methods: {
        change (val) {
            this.flg = val
        },
        // 路由跳转路径拼接
        routerPath (path) {
            return this.$route.matched[1].path + '/' + path
        },
        // 直接进行路由跳转路径
        routerPush (path) {
            this.$router.push(this.$route.matched[1].path + '/' + path)
        },
        GetIntegral () {
            let _this = this
            _this.integral = {}
            getIntegralMsg({
                uid: this.leftInfo.uid
            }).then(results => {
                this.integral = results.data.Body
            }).catch(err => {
                console.log(err)
            })
        },
        GetJCountIntegral () {
            let _this = this
            _this.JcountIntegral = {}
            getIntegralStatus({
                uid: this.leftInfo.uid,
                dataSource: 13
            }).then(results => {
                this.JcountIntegral = results.data.Body
            }).catch(error => {
                console.log(error)
            })
        },

        GetTCountIntegral () {
            let _this = this
            _this.TcountIntegral = {}
            getIntegralStatus({
                uid: this.leftInfo.uid,
                dataSource: 14
            }).then(results => {
                this.TcountIntegral = results.data.Body
            }).catch(error => {
                console.log(error)
            })
        },
        countHandlerIntegral () {
            let _this = this
            _this.countIntegral = {}
            PersonHandlerIntegralNum({
                userCard: this.leftInfo.app_cardNo
            }).then(results => {
                this.countIntegral = results.data.Body
            })
        },
        countComplaints () {
            let _this = this
            _this.complaints = {}
            countcomplaintsIntegral({
                uid: this.leftInfo.uid
            }).then(results => {
                this.complaints = results.data.Body
            })
        },
        ProblemIntegral () {
            let _this = this
            getProblemIntegral({
                pmId: this.leftInfo.uid
            }).then(result => {
                _this.tIntegralObject = result.data.Body.problemIntegralList
                _this.tIntegral = result.data.Body.problemIntegralList.map(list => list.integral).reduce((acc, cur) => (parseFloat(cur) + acc), 0)
            }).catch(err => {
                console.log(err)
            })
        }
    },
    computed: {
        ...mapGetters(['leftInfo'])
    },
    watch: {
        leftInfo () {
            this.GetIntegral()
            this.GetJCountIntegral()
            this.GetTCountIntegral()
            this.countHandlerIntegral()
            this.countComplaints()
        }
        // $route () {
        //     this.change()
        // }
    }
}

</script>
<style scoped>
.bgcolor {
  color: #fff;
  background-color: #409eff;
}
</style>
